//
//  kqyLoginButton.m
//  百思不得姐os1
//
//  Created by kqy on 8/3/16.
//  Copyright © 2016 kqy. All rights reserved.
//

#import "kqyLoginButton.h"

@implementation kqyLoginButton

- (void)layoutSubviews {
    [super layoutSubviews];
//    self.imageView.frame.origin.y = 0;
    CGRect tempYFrame = self.imageView.frame;
    tempYFrame.origin.y = 0;
    self.imageView.frame = tempYFrame;
    
//    self.imageView.center.x = self.frame.size.width * 0.5;
    CGPoint tempXCenter = self.imageView.center;
    tempXCenter.x = self.frame.size.width * 0.5;
    self.imageView.center = tempXCenter;
    
    CGRect tempTitleXFrame = self.titleLabel.frame;
    tempTitleXFrame.origin.x = 0;
    self.titleLabel.frame = tempTitleXFrame;
    
    CGRect tempTitleYFrame = self.titleLabel.frame;
    tempTitleYFrame.origin.y = CGRectGetMaxY(self.imageView.frame);
    self.titleLabel.frame = tempTitleYFrame;
    
    // calculate for height
    CGFloat selfHeight = self.frame.size.height;
    CGFloat titleY = self.titleLabel.frame.origin.y;
    
    // label height
    CGRect LblTempFrame = self.titleLabel.frame;
    LblTempFrame.size.height = selfHeight - titleY;
    self.titleLabel.frame = LblTempFrame;
    
    //
    CGRect titleTempWidth = self.titleLabel.frame;
    titleTempWidth.size.width = self.frame.size.width;
    self.titleLabel.frame = titleTempWidth;
    
}
//- (instancetype)initWithFrame:(CGRect)frame {
//    if (self = [super initWithFrame:frame]) {
//        self.titleLabel.textAlignment = NSTextAlignmentCenter;
//    }
//    return self;
//}

+ (instancetype)buttonCreate {
    return [[self alloc] init];
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
    }
    return self;
}

//- (CGRect)imageRectForContentRect:(CGRect)contentRect {
//    
//}
@end
